package PTA.javaA;

import java.util.Arrays;
import java.util.Scanner;

class PersonOverride{
    private String name;
    private int age;
    private boolean gender;
    PersonOverride(String name,int age,boolean gender){
        this.name = name;
        this.age=age;
        this.gender=gender;
    }
    PersonOverride(){
        this("default",1,true);
    }

    @Override
    public String toString() {
        return name+"-"+age+"-"+gender;
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + age;
        result = prime * result + (gender ? 1231 : 1237);
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        PersonOverride other = (PersonOverride) obj;
        if (age != other.age)
            return false;
        if (gender != other.gender)
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }

}
public class ex17 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n1 = in.nextInt();
        int i;
        PersonOverride person1[] = new PersonOverride[n1];
        for (i = 0; i < n1; i++) {
            person1[i] = new PersonOverride();
        }
        int n2 = in.nextInt();
        PersonOverride person2[] = new PersonOverride[n2];
        int count=0;
        PersonOverride p = null;
        for (i = 0; i < n2; i++) {
            p = new PersonOverride(in.next(), in.nextInt(), in.nextBoolean());
            int j = 0;
            while (j < count) {
                if (p.equals(person2[j]))
                    break;
                j++;
            }
            if (j >= count) {
                person2[count] = p;
                count++;
            }
        }
        in.close();
        for(i=0;i<n1;i++)
        {
            System.out.println(person1[i].toString());
        }
        for (i = 0; i < count; i++) {
            System.out.println(person2[i].toString());
        }
        System.out.println(count);
        System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
    }
}